<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\index\controller;

/**
 * 会员控制器
 */
class User extends IndexBase
{
    /**
     * 简历列表
     */
    public function yjtj()
    {
        $data=$this->param;
        if(!empty($data['id'])){
            $info=db('user')->field('id,username,name,headimg')->where('id',$data['id'])->find();
            $where = " tjid=".$data['id'];
            !empty($data['stat']) && $where.=" and create_time >= ".strtotime($data['stat'])." ";
            !empty($data['end']) && $where.=" and create_time <= ".strtotime($data['end'])." ";
            $info['num']=db('user')->where($where)->count();

            $gryh=db('user')->where($where." and `is`=1")->column('id');
            $info['gryh']=count($gryh);
            if(!empty($gryh)){
                $info['gryhs']=db('resume')->where("user_id IN(".implode(',',$gryh).") and position != ''")->count();
            }else{
                $info['gryhs']=0;
            }

            $info['qyyh']=db('user')->where($where.' and `is`=2 ')->count();

            $qyyhs=db('user')->where($where.' and `is`=2 and gsrz=1')->column('id');
            $info['qyyhs']=count($qyyhs);
            $sum=0;
            foreach($qyyhs as $v){
                $is=db('work')->where('user_id',$v)->value('id');
                if(!empty($is)){
                    $sum+=1;
                }
            }
            $info['fbzw']=$sum;
            $this->assign('info',$info );
        }
        return $this->fetch('yjtj');
    }
    /**
     * 简历列表
     */
    public function resumeList()
    {
        $where = [];
        $where['a.position'] = ['neq',''];
        !empty($data['search_data']) && $where['b.name|b.username|a.position'] = ['like', '%'.$data['search_data'].'%'];

        $list=$this->logicUser->getResumeList($where);
        $this->assign('list',$list );
        return $this->fetch('resume_list');
    }
    /**
     * 服务商添加
     */
    public function serviceAdd()
    {
        $data=$this->param;
        IS_POST && $this->jump($this->logicUser->serviceAdd($data));
        if(!empty($data['id'])){
            $info = db('service')->where('id',$data['id'])->find();
            $info['addresss']=db('region')->where('code',$info['code'])->value('name');
            $this->assign('info', $info);
        }
        return $this->fetch('service_edit');
    }
    /**
     * 删除服务商
     * @param id
     * @return array
     * @throws UnauthorizedException
     */
    public function delService(){
        $param=$this->param;
        db('service')->startTrans();
        $user_id=db('service')->where('id',$param['id'])->value('user_id');
        $res=db('service')->where('id',$param['id'])->delete();
        $re=db('user')->where('id',$user_id)->update(array('is_service'=>0));
        if($res && $re){
            db('service')->commit();
            action_log('删除服务商', '删除服务商，id：' . $param['id']);
            $this->jump(['success', '删除成功']);
        }else{
            db('service')->rollback();
            $this->jump(['error', '删除失败']);
        }
    }
    /**
     * 服务商申请列表
     */
    public function serviceList()
    {
        $where = [];
        !empty($data['search_data']) && $where['b.name|b.username|a.address'] = ['like', '%'.$data['search_data'].'%'];
        $list=$this->logicUser->getServiceList($where);
        $this->assign('list',$list);
        return $this->fetch('service_list');
    }
    /**
     * 服务商申请列表
     */
    public function agentList()
    {
        $where = [];
        !empty($data['search_data']) && $where['b.name|b.username|a.address'] = ['like', '%'.$data['search_data'].'%'];
        $list=$this->logicUser->getAgentList($where);
        $this->assign('list',$list);
        return $this->fetch('agent_list');
    }

	/**
     * 公司认证列表
     */
    public function companyList()
    {        
        $where = $this->logicUser->getWheres($this->param);
        $list=$this->logicUser->getCompanyList($where);
		foreach($list as $k=>$v){
			$list[$k]['typeName']=db('company_type')->where('id',$v['type'])->value('name');
			$list[$k]['numName']=db('company_num')->where('id',$v['num'])->value('name');
		}
        $this->assign('list',$list);
        return $this->fetch('company_list');
    }
    /**
     * 删除动态
     * @param id
     * @return array
     * @throws UnauthorizedException
     */
    public function deltrend(){
        $param=$this->param;
        db('trend')->startTrans();
        $thumbs=db('trend')->where('id',$param['id'])->value('thumbs');
        $arr=explode(',',substr($thumbs, 0, -1));
        $res=db('trend')->where('id',$param['id'])->delete();
        if($res){
            $re=db('zan')->where('t_id='.$param['id'])->delete();
            foreach($arr as $val){
                if(!empty($val)){
                    @unlink($_SERVER['DOCUMENT_ROOT'].$val);
                }
            }
            db('trend')->commit();
            action_log('删除动态', '删除动态，trend_id：' . $param['id']);
            $this->jump(['success', '删除成功']);
        }else{
            db('trend')->rollback();
            $this->jump(['error', '删除失败']);
        }
    }
    /**
     * 动态列表
     */
    public function trend_list()
    {
        $data=$this->param;
        $where=[];
        !empty($data['search_data']) && $where['m.cont|b.username|b.name'] = ['like', '%'.$data['search_data'].'%'];
        $list=$this->logicUser->getTrendList($where);
        foreach($list as $k=>$v){
            if(!empty($v['thumbs'])){
                $list[$k]['thumbs']=explode(',',substr($v['thumbs'],0,-1));
            }
        }
        $this->assign('list',$list);
        return $this->fetch('trend_list');
    }
    /**
     * 删除意见反馈
     * @param id
     * @return array
     * @throws UnauthorizedException
     */
    public function delsuggest(){
        $param=$this->param;
        $thumbs=db('suggest')->where('id',$param['id'])->value('imgs');
        $arr=explode(',',substr($thumbs, 0, -1));
        $res=db('suggest')->where('id',$param['id'])->delete();
        if($res){
            foreach($arr as $val){
                if(!empty($val)){
                    @unlink($_SERVER['DOCUMENT_ROOT'].$val);
                }
            }
            action_log('删除意见反馈', '删除意见反馈，suggest_id：' . $param['id']);
            $this->jump(['success', '删除成功']);
        }else{
            $this->jump(['error', '删除失败']);
        }
    }
    /**
     * 意见反馈列表
     */
    public function suggest_list()
    {
        $data=$this->param;
        $where=[];
        !empty($data['search_data']) && $where['m.cont|b.username|b.name'] = ['like', '%'.$data['search_data'].'%'];
        $list=$this->logicUser->getSuggestList($where);
        foreach($list as $k=>$v){
            if(!empty($v['imgs'])){
                $list[$k]['imgs']=explode(',',substr($v['imgs'],0,-1));
            }
        }
        $this->assign('list',$list);
        return $this->fetch('suggest_list');
    }
    /**
     * 删除投诉
     * @param id
     * @return array
     * @throws UnauthorizedException
     */
    public function delreport(){
        $param=$this->param;
        $thumbs=db('report')->where('id',$param['id'])->value('imgs');
        $arr=explode(',',substr($thumbs, 0, -1));
        $res=db('report')->where('id',$param['id'])->delete();
        if($res){
            foreach($arr as $val){
                if(!empty($val)){
                    @unlink($_SERVER['DOCUMENT_ROOT'].$val);
                }
            }
            action_log('删除投诉', '删除投诉，report_id：' . $param['id']);
            $this->jump(['success', '删除成功']);
        }else{
            $this->jump(['error', '删除失败']);
        }
    }
    /**
     * 举报列表
     */
    public function report_list()
    {
        $data=$this->param;
        $where=[];
        !empty($data['search_data']) && $where['m.cont|b.username|b.name'] = ['like', '%'.$data['search_data'].'%'];
        $list=$this->logicUser->getReportList($where);
        foreach($list as $k=>$v){
            if(!empty($v['resume_id'])){
                $list[$k]['resume']=db('resume')->where('resume_id',$v['resume_id'])->value('name');
            }
            if(!empty($v['work_id'])){
                $list[$k]['work']=db('work')->where('id',$v['work_id'])->value('title');
            }
            if(!empty($v['imgs'])){
                $list[$k]['imgs']=explode(',',substr($v['imgs'],0,-1));
            }
        }
        $this->assign('list',$list);
        return $this->fetch('report_list');
    }
    /**
     * 简历详情
     */
    public function resumeInfo()
    {
        $data=$this->param;
        if(!empty($data['id'])){
            $info=db('resume')->where('user_id',$data['id'])->find();
        }elseif(!empty($data['resume_id'])){
            $info=db('resume')->where('resume_id',$data['resume_id'])->find();
        }else{
            $info=array();
        }
        if(!empty($info)){
            $info['experienceList']=db('resume_experience')->where('resume_id',$info['resume_id'])->select();
            $info['educationList']=db('resume_education')->where('resume_id',$info['resume_id'])->select();
            $info['headimg']=db('user')->where('id',$info['user_id'])->value('headimg');
        }
        if(!empty($info['position_id'])){
            $info['positionName']=db('position_cat')->where('id',$info['position_id'])->value('catname');
        }
        if(!empty($info['education_id'])){
            $info['education']=db('education')->where('education_id',$info['education_id'])->value('name');
        }
        $this->assign('info',$info);
        return $this->fetch('resumeInfo');
    }
	/**
     * 代理申请列表
     */
    public function agentApply()
    {
        
        $where = [];
        isset($data['stat']) && $data['stat']!=9 && $where['m.stat']=$data['stat'];
        !empty($data['search_data']) && $where['b.username|b.name'] = ['like', '%'.$data['search_data'].'%'];   
        $list=$this->logicUser->getApplyList($where);
		foreach($list as $k=>$v){
			$list[$k]['num']=db('user')->where('tjid',$v['user_id'])->count();
		}
        $this->assign('list',$list);
        return $this->fetch('apply_list');
    }
	/**
     * 余额明细
     */
    public function moneyyj()
    {
        $list=$this->logicUser->getMoneyyjList($this->param);
        $this->assign('list',$list);
        return $this->fetch('moneyyj');
    }
    /**
     * 拨付现金明细
     */
    public function moneyyjList()
    {
        $data=$this->param;
        $data['type']=0;
        $list=$this->logicUser->getMoneyyjList($data);
        foreach($list as $k=>$v){
            $list[$k]['username']=db('user')->where('id',$v['user_id'])->value('username');
            $list[$k]['name']=db('user')->where('id',$v['user_id'])->value('name');
            if(!empty($v['getid'])){
                $list[$k]['names']=db('member')->where('id',$v['getid'])->value('username');
            }else{
                $list[$k]['names']='';
            }
        }
        $this->assign('list',$list);
        return $this->fetch('moneyyj_list');
    }
	/**
     * 权限明细
     */
    public function log_list()
    {
        $list=$this->logicUser->getLogList($this->param);
        $this->assign('list',$list);
        return $this->fetch('log_list');
    }
    /**
     * 权限明细
     */
    public function logList()
    {
        $data=$this->param;
        $data['key']=1;
        $list=$this->logicUser->getLogList($data);
        foreach($list as $k=>$v){
            $list[$k]['username']=db('user')->where('id',$v['user_id'])->value('username');
            $list[$k]['name']=db('user')->where('id',$v['user_id'])->value('name');
            if(!empty($v['getid'])){
                $list[$k]['names']=db('member')->where('id',$v['getid'])->value('username');
            }else{
                $list[$k]['names']='';
            }
        }
        $this->assign('list',$list);
        return $this->fetch('loglist');
    }
    /**
     * 会员列表
     */
    public function userList()
    {
        
        $where = $this->logicUser->getWhere($this->param);
        $list=$this->logicUser->getUserList($where);
		foreach($list as $k=>$v){
			$list[$k]['num']=db('user')->where('tjid',$v['id'])->count();
			$list[$k]['mdc']=db('money')->where('user_id',$v['id'])->count();
			$info=db('company')->field('resumeNum,workNum')->where('user_id',$v['id'])->find();
			$list[$k]['resumenum']=$info['resumeNum'];
			$list[$k]['worknum']=$info['workNum'];
            $list[$k]['resume_id']=db('resume')->where("position != '' and user_id=".$v['id'])->value('resume_id');
		}
		//var_dump($list);exit;
        $this->assign('list',$list );
        return $this->fetch('user_list');
    }
    /**
     * 用户排序列表
     */
    public function userOrderList()
    {
        $where = $this->logicUser->getWhere();
        $data=$this->param;
        $order='m.login_time desc';
        !empty($data['sort']) && $order="m.".$data['sort']." ".$data['type'];
        $list=$this->logicUser->getUserList($where,'m.*,b.username as tjusername,b.name as tjname',$order);
        foreach($list as $k=>$v){
            $list[$k]['mdc']=db('money')->where('user_id',$v['id'])->count();
            $list[$k]['num']=db('user')->where('tjid',$v['id'])->count();
            $id=$v['id'];
            $list[$k]['sum']=db('user')->where(" nocodea like '%$id%'")->count();
        }
        $this->assign('list',$list );
        return $this->fetch('user_order_list');
    }
    /**
     * 会员导出
     */
    public function exportUserList()
    {
        !empty($data['tjid']) && $where['m.tjid']=$data['tjid'];
        $where = $this->logicUser->getWhere($this->param);
        
        $this->logicUser->exportUserList($where);
    }
        
    /**
     * 会员编辑
     */
    public function userEdit()
    {
        IS_POST && $this->jump($this->logicUser->userEdit($this->param));
        
        $info = $this->logicUser->getUserInfo(['id' => $this->param['id']]);

        $this->assign('info', $info);

        return $this->fetch('user_edit');
    }
    /**
     * 公司信息编辑
     */
    public function companyEdit()
    {
        IS_POST && $this->jump($this->logicUser->companyEdit($this->param));

        $info = db('company')->where('company_id',$this->param['company_id'])->find();
        $cinfo=db('company_num')->select();
        $tinfo=db('company_type')->select();
        $this->assign('info', $info);
        $this->assign('cinfo', $cinfo);
        $this->assign('tinfo', $tinfo);
        return $this->fetch('company_edit');
    }
	/**
     * 会员添加
     */
    public function userAdd()
    {
        
        IS_POST && $this->jump($this->logicUser->userAdd($this->param));
        
        return $this->fetch('user_add');
    }
    
    /**
     * 会员删除
     */
    public function userDel($id = 0)
    {
        
        return $this->jump($this->logicUser->userDel(['id' => $id]));
    }

    /**
     * 批量冻结
     */
    public function frozenUser()
    {
        $data=$this->param;
        if(!empty($data)){
            return $this->logicUser->frozenUser($data);
        }else{
            return $this->fetch('frozen');
        }
    }

    /**
     * 修改密码
     */
    public function editPassword()
    {
        
        IS_POST && $this->jump($this->logicUser->editPassword($this->param));
        
        $info = $this->logicUser->getMemberInfo(['id' => MEMBER_ID]);
        
        $this->assign('info', $info);
        
        return $this->fetch('edit_password');
    }
	/**
     * 数据状态设置
     */
    public function setStatus()
    {
        
        $this->jump($this->logicAdminBase->setStatus('user', $this->param));
    }
	/**
     * 数据状态设置
     */
    public function setStat()
    {
        
        $this->jump($this->logicAdminBase->setStat('company', $this->param,'company_id'));
    }
	/**
     * 编辑次数
     */
    public function editNum()
    {
        $data=$this->param;		
		//db('company')->startTrans();
		if(!empty($data['resumeNum'])){
			$str='；简历查看权限：'.$data['resumeNum'];
			$re=logAdd($data['user_id'],MEMBER_ID,1,'后台拨付',$data['resumeNum'],1);
		}else{
			$str='；发布职位权限：'.$data['workNum'];
			$re=logAdd($data['user_id'],MEMBER_ID,0,'后台拨付',$data['workNum'],1);
		}
        !$re && action_log('编辑', '拨付发布查看权限，user_id：' . $data['user_id'].$str);
		if(!$re){
			//db('company')->commit();
			echo json_encode(array('code'=>0,'msg'=>'操作成功'));exit;
		}else{
			//db('company')->rollback();
			echo json_encode(array('code'=>1,'msg'=>$re));exit;
		}	
    }
	/**
     * 拨付现金
     */
    public function editMoney()
    {
        $data=$this->param;		
		//db('company')->startTrans();
		if(empty($data['money']) || !is_numeric($data['money'])){
			echo json_encode(array('code'=>1,'msg'=>'请输入拨付金额'));exit;
		}
		$re=moneyyj_log($data['money'],$data['user_id'],0,MEMBER_ID);
        $re && action_log('拨付现金', '拨付现金，user_id：' . $data['user_id'].'；money：'.$data['money']);
		if($re){
			//db('company')->commit();
			echo json_encode(array('code'=>0,'msg'=>'操作成功'));exit;
		}else{
			//db('company')->rollback();
			echo json_encode(array('code'=>1,'msg'=>$re));exit;
		}	
    }
	/**
     * 重置密码
     */
    public function resetPassword()
    {
        $data=$this->param;		
		if(empty($data['password']) || strlen($data['password']) < 6){
			echo json_encode(array('code'=>1,'msg'=>'请输入不少于6位的密码'));exit;
		}
		$salt=rand(1000,9999);
		$date['salt']=$salt;
		$date['password']=data_md5_key($data['password'],$salt);
		$re=db('user')->where('id',$data['id'])->update($date);
        $re && action_log('重置密码', '重置密码，user_id：' . $data['id'].'；password：'.$data['password']);
		if($re){
			//db('company')->commit();
			echo json_encode(array('code'=>0,'msg'=>'操作成功'));exit;
		}else{
			//db('company')->rollback();
			echo json_encode(array('code'=>1,'msg'=>$re));exit;
		}	
    }
	/**
     * 数据状态设置
     */
    public function setStats()
    {   
		$param=$this->param;
       
        db('user')->startTrans();
		if($param['stat'] == 0){
			$result = db('apply')->where('id',$param['id'])->update(array('stat'=>1));
			$res=db('user')->where('id',$param['user_id'])->update(array('is_agent'=>1));
		}else{
			$result = db('apply')->where('id',$param['id'])->update(array('stat'=>0));
			$res=db('user')->where('id',$param['user_id'])->update(array('is_agent'=>0));
		}
        if($res && $result){
			action_log('代理申请审核', '数据状态调整' . '，model：apply，id：' . $param['id'] . '，stat：' . $param['stat']);
			db('user')->commit();
		}else{
			db('user')->rollback();
		}
        $this->jump(($res && $result) ? [RESULT_SUCCESS, '操作成功'] : [RESULT_ERROR, '系统繁忙，操作失败']);
    }
    /**
     * 删除简历
     */
    public function delResume()
    {
        $data=$this->param;
        db('resume')->startTrans();
        $user_id=db('resume')->where('resume_id',$data['resume_id'])->value('user_id');
        db('shoucang')->where('user_id',$user_id)->delete();
        db('resume_education')->where('resume_id',$data['resume_id'])->delete();
        db('resume_experience')->where('resume_id',$data['resume_id'])->delete();
        db('chat')->where('resume_id',$data['resume_id'])->delete();
        db('shoucang')->where('resume_id',$data['resume_id'])->delete();
        db('deliver_resume')->where('resume_id',$data['resume_id'])->delete();
        $res=db('resume')->where('resume_id',$data['resume_id'])->delete();
        $res && action_log('删除简历', '删除简历，resume_id：' . $data['resume_id']);
        if($res){
            db('resume')->commit();
            echo json_encode(array('code'=>0,'msg'=>'操作成功'));exit;
        }else{
            db('resume')->rollback();
            echo json_encode(array('code'=>1,'msg'=>'操作失败'));exit;
        }
    }
    /**
     * 删除公司信息
     */
    public function delCompany()
    {
        $data=$this->param;
        $info=db('company')->where('company_id',$data['company_id'])->find();
        $res=db('company')->where('company_id',$data['company_id'])->delete();
        if($res != false){
            @unlink($_SERVER['DOCUMENT_ROOT'].$info['img']);
            $arr=explode(',',substr($info['imgs'], 0, -1));
            foreach($arr as $k=>$v){
                @unlink($_SERVER['DOCUMENT_ROOT'].$v);
            }
            action_log('删除公司信息', '删除简历，company_id：' . $data['company_id'] .'，user_id：'.$info['user_id']);
            $this->jump(['success', '删除公司信息成功']);
        }else{
            $this->jump(['error', '删除公司信息失败']);
        }
    }
    public function delUserImg(){
        $id=$this->param['id'];
        $headimg=db('user')->where('id',$id)->value('headimg');
        $res=db('user')->where('id',$id)->update(array('headimg'=>''));
        if($res != false){
            @unlink($_SERVER['DOCUMENT_ROOT'].$headimg);
            echo json_encode(array('code'=>0,'msg'=>'操作成功'));exit;
        }else{
            echo json_encode(array('code'=>1,'msg'=>'系统繁忙，请稍后重试'));exit;
        }

    }
    //旋转图片
    //src 图片完整路径
    //$direction 1顺时针90   2 逆时针90
    public function imgturn()
    {
        $data=$this->param;
        $src=$_SERVER['DOCUMENT_ROOT'].$data['path'];
        $direction=1;
        $ext = pathinfo($src)['extension'];
        switch ($ext) {
            case 'gif':
                $img = imagecreatefromgif($src);
                break;
            case 'jpg':
            case 'jpeg':
                $img = imagecreatefromjpeg($src);
                break;
            case 'png':
                $img = imagecreatefrompng($src);
                break;
            default:
                die('图片格式错误!');
                break;
        }
        $width = imagesx($img);
        $height = imagesy($img);
        $img2 = imagecreatetruecolor($height,$width);
        //顺时针旋转90度
        if($direction==1)
        {
            for ($x = 0; $x < $width; $x++) {
                for($y=0;$y<$height;$y++) {
                    imagecopy($img2, $img, $height-1-$y,$x, $x, $y, 1, 1);
                }
            }
        }else if($direction==2) {
            //逆时针旋转90度
            for ($x = 0; $x < $height; $x++) {
                for($y=0;$y<$width;$y++) {
                    imagecopy($img2, $img, $x, $y, $width-1-$y, $x, 1, 1);
                }
            }
        }
        switch ($ext) {
            case 'jpg':
            case "jpeg":
                imagejpeg($img2, $src, 100);
                break;

            case "gif":
                imagegif($img2, $src, 100);
                break;

            case "png":
                imagepng($img2, $src, 100);
                break;

            default:
                die('图片格式错误!');
                break;
        }
        imagedestroy($img);
        imagedestroy($img2);
        echo json_encode(array('code'=>0,'msg'=>'操作成功'));exit;
    }
    /**
     * 检查用户
     */
    public function checkUsername()
    {
        $data=$this->param;
        $info=db('user')->field('id,name,nocodea')->where('username',$data['username'])->find();
        if($info['id'] == $data['user_id']){
            echo json_encode(array('code'=>1,'msg'=>'分享人不能为本人'));exit;
        }else{
            $arr=explode(',',$info['nocodea']);
            if(in_array($data['user_id'],$arr)){
                echo json_encode(array('code'=>1,'msg'=>'该用户为自己团队人员，不能作为分享人'));exit;
            }
        }
        if(!empty($info['name'])){
            echo json_encode(array('code'=>0,'msg'=>$info['name']));exit;
        }else{
            echo json_encode(array('code'=>1,'msg'=>'不存在该分享人'));exit;
        }
    }
    /**
     * 检查用户
     */
    public function checkService()
    {
        $data=$this->param;
        $info=db('user')->field('id,name')->where('username',$data['username'])->find();
        if(empty($info)){
            echo json_encode(array('code'=>1,'msg'=>'用户不存在'));exit;
        }else{
            //$is=db('service')->where('user_id',$info['id'])->value('id');
            //if(!empty($is)){
            //    echo json_encode(array('code'=>1,'msg'=>'该用户已成为服务商'));exit;
            //}
            echo json_encode(array('code'=>0,'msg'=>$info['name']));exit;
        }
    }
    /**
     * 检查地区
     */
    public function checkAddress()
    {
        $data=$this->param;
        $a=$data['addresss'];
        $info=db('region')->field('code,name')->where("name like '%$a%'")->find();
        if(empty($info)){
            echo json_encode(array('code'=>1,'msg'=>'地区不存在'));exit;
        }else{
            $is=db('service')->where('address',$info['code'])->value('id');
            if(!empty($is)){
                echo json_encode(array('code'=>1,'msg'=>'该地区已分配服务商，请换个地区'));exit;
            }
        }
        echo json_encode(array('code'=>0,'msg'=>$info['name']));exit;
    }
    /**
     * 个人列表
     */
    public function buserList()
    {
        $data=$this->param;
        $where = [];
        $where['m.is']=1;
        if(USER_ID != 1){
        	$where['m.nocodea']=['like', '%,'.USER_ID.',%'];
        }
       // $where['b.position']=['neq',''];
        !empty($data['search_data']) && $where['m.phone|m.username|m.name'] = ['like', '%'.$data['search_data'].'%'];
        $list=$this->logicUser->getUsersList($where);
        foreach($list as $k=>$v){
            $list[$k]['chat']=db('chat')->where('getid',$v['id'])->count();
            $list[$k]['sc']=db('shoucang')->where(array('user_id'=>$v['id'],'type'=>1))->count();
            $list[$k]['td']=db('deliver_resume')->where(array('user_id'=>$v['id']))->count();
            $list[$k]['resume_id']=db('resume')->where("position != '' and user_id=".$v['id'])->value('resume_id');
        }
        $this->assign('list',$list );
        return $this->fetch('buser_list');
    }
    /**
     * 企业列表
     */
    public function cuserList()
    {
        $where = [];
        $where['m.is']=2;
        //$this->param['gsrz']=1;
        if(USER_ID != 1){
        	$where['m.nocodea']=['like', '%,'.USER_ID.',%'];
        }
       !empty($data['search_data']) && $where['m.phone|m.username|m.name'] = ['like', '%'.$data['search_data'].'%'];
        $list=$this->logicUser->getUserList($where,'m.id,m.username,m.headimg,m.name,m.is_service','m.id desc');
        foreach($list as $k=>$v){
        	$list[$k]['tc']=db('series_order')->where(array('user_id'=>$v['id'],'stat'=>1))->count();
            $list[$k]['num']=db('work')->where('user_id',$v['id'])->count();
            $list[$k]['chat']=db('chat')->where('user_id',$v['id'])->count();
            $list[$k]['sc']=db('shoucang')->where(array('user_id'=>$v['id'],'type'=>1))->count();
            $list[$k]['ms']=db('interview')->where(array('user_id'=>$v['id']))->count();
            $list[$k]['lq']=db('interview')->where(array('user_id'=>$v['id'],'stat'=>1))->count();
        }
        $this->assign('list',$list );
        return $this->fetch('cuser_list');
    }
    /**
     * 企业列表
     */
    public function user_list()
    {
        $data=$this->param;
        if($data['type'] == 1){
            $where['m.user_id']=$data['user_id'];
           // !empty($data['search_data']) && $where['b.phone|b.username|b.name'] = ['like', '%'.$data['search_data'].'%'];
            $list=$this->logicUser->getChatList($where);
        }elseif($data['type'] == 2){
            $where['user_id']=$data['user_id'];
            $where['type']=1;
            $list=$this->logicUser->getShoucangList($where);
        }elseif($data['type'] == 3){
            $where['user_id']=$data['user_id'];
            $list=$this->logicUser->getInterviewList($where);
        }elseif($data['type'] == 4){
            $where['user_id']=$data['user_id'];
            $where['stat']=1;
            $list=$this->logicUser->getInterviewList($where);
        }elseif($data['type'] == 5){
            $where['m.getid']=$data['user_id'];
            $list=$this->logicUser->getChatLists($where);
        }else{
            $where['work_id']=$data['work_id'];
            $list=$this->logicUser->getResumeLists($where);
        }
        $this->assign('list',$list );
        return $this->fetch('userlist');
    }
}
